<template>
  <div>
    <div align="center">
      <label size="large" label-width="280px">— — — — — — — — — — </label><br/>
      <label size="large" label-width="280px">* * * 电梯风险模型评估 * * *</label><br/>
      <label size="large" label-width="280px">— — — — — — — — — — </label>
    </div>
    <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="180px">
      <el-row>
        <el-col :span="12">
      <el-form-item label="设备编号" prop="number">
        <el-input v-model="formData.number" placeholder="请输入设备编号" clearable :style="{width: '60%'}">
        </el-input>
      </el-form-item>
        </el-col>
        <el-col :span="12">
      <el-form-item label="运行年代" prop="yxnd">
        <el-select v-model="formData.yxnd" placeholder="请输入运行年代" clearable :style="{width: '60%'}">
          <el-option v-for="(item, index) in yxndOptions" :key="index" :label="item.label" :value="item.value"
                     :disabled="item.disabled"></el-option>
        </el-select>
      </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
        <el-form-item label="电梯近3年发生故障数量" prop="dtjs">
        <el-select v-model="formData.dtjs" placeholder="请输入电梯近3年发生故障数量" clearable :style="{width: '60%'}">
          <el-option v-for="(item, index) in dtjsOptions" :key="index" :label="item.label" :value="item.value"
                     :disabled="item.disabled"></el-option>
        </el-select>
      </el-form-item>
        </el-col>
          <el-col :span="12">
          <el-form-item label="所在建筑物类型" prop="szjz">
        <el-select v-model="formData.szjz" placeholder="请输入所在建筑物类型" clearable :style="{width: '60%'}">
          <el-option v-for="(item, index) in szjzOptions" :key="index" :label="item.label" :value="item.value"
                     :disabled="item.disabled"></el-option>
        </el-select>
      </el-form-item>
          </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
        <el-form-item label="建筑物层高" prop="jzwc">
        <el-select v-model="formData.jzwc" placeholder="请选择建筑物层高" clearable :style="{width: '60%'}">
          <el-option v-for="(item, index) in jzwcOptions" :key="index" :label="item.label" :value="item.value"
                     :disabled="item.disabled"></el-option>
        </el-select>
      </el-form-item>
        </el-col>
          <el-col :span="12">
          <el-form-item label="电梯类型" prop="dtlx">
        <el-select v-model="formData.dtlx" placeholder="请选择电梯类型" clearable :style="{width: '60%'}">
          <el-option v-for="(item, index) in dtlxOptions" :key="index" :label="item.label" :value="item.value"
                     :disabled="item.disabled"></el-option>
        </el-select>
      </el-form-item>
          </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
        <el-form-item label="是否安装在线监测系统" prop="sfaz">
        <el-select v-model="formData.sfaz" placeholder="请选择是否安装在线监测系统" clearable :style="{width: '60%'}">
          <el-option v-for="(item, index) in sfazOptions" :key="index" :label="item.label" :value="item.value"
                     :disabled="item.disabled"></el-option>
        </el-select>
      </el-form-item>
        </el-col>
          <el-col :span="12">
          <el-form-item label="距离上一次维保时间" prop="jlsy">
        <el-select v-model="formData.jlsy" placeholder="请选择距离上一次维保时间" clearable :style="{width: '60%'}">
          <el-option v-for="(item, index) in jlsyOptions" :key="index" :label="item.label" :value="item.value"
                     :disabled="item.disabled"></el-option>
        </el-select>
      </el-form-item>
          </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
        <el-form-item label="是否报警" prop="sfbj">
        <el-select v-model="formData.sfbj" placeholder="请选择是否报警" clearable :style="{width: '60%'}">
          <el-option v-for="(item, index) in sfbjOptions" :key="index" :label="item.label" :value="item.value"
                     :disabled="item.disabled"></el-option>
        </el-select>
      </el-form-item>
        </el-col>
          <el-col :span="12">
          <el-form-item label="是否困人" prop="sfkr">
        <el-select v-model="formData.sfkr" placeholder="请选择是否困人" clearable :style="{width: '60%'}">
          <el-option v-for="(item, index) in sfkrOptions" :key="index" :label="item.label" :value="item.value"
                     :disabled="item.disabled"></el-option>
        </el-select>
      </el-form-item>
          </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
        <el-form-item label="报警处置情况" prop="bjcz">
        <el-select v-model="formData.bjcz" placeholder="请选择报警处置情况" clearable :style="{width: '60%'}">
          <el-option v-for="(item, index) in bjczOptions" :key="index" :label="item.label" :value="item.value"
                     :disabled="item.disabled"></el-option>
        </el-select>
      </el-form-item>
        </el-col>
      </el-row>
      <el-form-item size="large">
        <el-button type="primary" @click="submitForm">提交</el-button>
        <el-button @click="resetForm">重置</el-button>
      </el-form-item>
    </el-form>
    <el-dialog
      title="评估结果"
      :visible.sync="centerDialogVisible"
      width="30%"
      center>
      <span>编号:{{number}}；得分：{{score}}；风险等级：{{name}}</span>
      <span slot="footer" class="dialog-footer">
    <el-button @click="centerDialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="centerDialogVisible = false">确 定</el-button>
  </span>
    </el-dialog>
  </div>
</template>
<script>
  import {handleDT} from "../../../api/edu/risk";

  export default {
    components: {},
    props: [],
    data() {
      return {
        centerDialogVisible: false,
        formData: {
          number: undefined,
          yxnd: undefined,
          dtjs: undefined,
          szjz: undefined,
          jzwc: undefined,
          dtlx: undefined,
          sfaz: undefined,
          jlsy: undefined,
          sfbj: undefined,
          sfkr: undefined,
          bjcz: undefined,
        },
        rules: {
          number: [{
            required: true,
            message: '请输入设备编号',
            trigger: 'blur'
          }],
          yxnd: [],
          dtjs: [],
          szjz: [],
          jzwc: [],
          dtlx: [],
          sfaz: [],
          jlsy: [],
          sfbj: [],
          sfkr: [],
          bjcz: [],
        },
        yxndOptions: [{
          "label": "≤5年",
          "value": 1
        }, {
          "label": "大于5年，≤15年",
          "value": 2
        }, {
          "label": "＞15年",
          "value": 3
        }],
        dtjsOptions: [{
          "label": "0次",
          "value": 1
        }, {
          "label": "大于0，≤3次",
          "value": 2
        }, {
          "label": "＞3次",
          "value": 3
        }],
        szjzOptions: [{
          "label": "居民住宅使用",
          "value": 1
        }, {
          "label": "商业综合体、酒店、写字楼使用",
          "value": 2
        }, {
          "label": "学校、医院、车站等人员密集公共场所",
          "value": 3
        }, {
          "label": "企业",
          "value": 4
        }],
        jzwcOptions: [{
          "label": "6层及以下",
          "value": 1
        }, {
          "label": "6层以上，18层及以下",
          "value": 2
        }, {
          "label": "18层以下",
          "value": 3
        }],
        dtlxOptions: [{
          "label": "直梯",
          "value": 1
        }, {
          "label": "扶梯",
          "value": 2
        }],
        sfazOptions: [{
          "label": "否",
          "value": 1
        }, {
          "label": "是",
          "value": 2
        }],
        jlsyOptions: [{
          "label": "≤10天",
          "value": 1
        }, {
          "label": ">10天，≤30天",
          "value": 2
        }, {
          "label": "＞30天",
          "value": 3
        }],
        sfbjOptions: [{
          "label": "否",
          "value": 1
        }, {
          "label": "是",
          "value": 2
        }],
        sfkrOptions: [{
          "label": "否",
          "value": 1
        }, {
          "label": "是",
          "value": 2
        }],
        bjczOptions: [{
          "label": "正在处置",
          "value": 1
        }, {
          "label": "未处置",
          "value": 2
        }],
      }
    },
    computed: {},
    watch: {},
    created() {},
    mounted() {},
    methods: {
      submitForm() {
        handleDT(this.formData).then(response => {
          console.log(response)
          this.number = response.number;
          this.score = response.score,
            this.name = response.name,
            this.centerDialogVisible = true
        });
      },
      resetForm() {
        this.$refs['elForm'].resetFields()
      },
    }
  }

</script>
<style>
</style>
